//
//  QCFixViewController.swift
//  爱汽车
//
//  Created by liujianlong on 2023/8/25.
//

import UIKit

class QCFixViewController: QCViewController {
    var array = ["维修模式"]
    var values = [false]
    override func viewDidLoad() {
        super.viewDidLoad()
        initUI()
    }
    
    override func initUI() {
        title = LS("维修模式")
        tableView.delegate = self
        tableView.dataSource = self
        tableView.register(QCSettingCell.nib(), forCellReuseIdentifier: QCSettingCell.ID())
        tableView.snp.makeConstraints { make in
            make.edges.equalToSuperview()
        }
    }
    
    override var base_info: [UInt8]{
        didSet{
            let data = [UInt8](base_info[AI_index..<base_info.count])
            if recived == false {
                recived = true
                return}
            values = [Int(data[0]) == 3]
            tableView.reloadData()
        }
    }
}
//MARK: - UITableViewDataSource
extension QCFixViewController:UITableViewDataSource
{
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return array.count
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: QCSettingCell.ID()) as! QCSettingCell
        cell.title.text = LS(array[indexPath.row])
        cell.type = .switchBtn(values[indexPath.row])
        cell.block = {[weak self] ison in
            self?.recived = false
            BLEData.appSetDataToPer(AIQC.isFixMode.cmd, ison ? "01" : "00").write
        }
        return cell
    }
}
//MARK: - UITableViewDelegate
extension QCFixViewController:UITableViewDelegate{
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    }
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 0
    }
    
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return nil
    }
    
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return nil
    }
}
